package hhm.android.myframe

import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import hhm.android.base.activity.BaseActivity
import kotlinx.android.synthetic.main.activity_third.*
import java.util.*

class ThirdActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setTitleMainColorAndTextWhite()
        setContentView(R.layout.activity_third)
        recyclerView.layoutManager = LinearLayoutManager(this)
        val l = ArrayList<Int>()
        l.add(1)
        l.add(2)
        l.add(3)
        l.add(4)
        l.add(5)
        l.add(6)
        l.add(7)
        val adapter = BaseAdapter(this, l)
        recyclerView.adapter = adapter

        srl.setOnLoadMoreListener {
            l.add(8)
            l.add(9)
            adapter.setData(l)
            srl.finishLoadMore(1000)
        }

        srl.setOnRefreshListener {
            l.clear()
            l.add(1)
            l.add(2)
            l.add(3)
            l.add(4)
            l.add(5)
            l.add(6)
            l.add(7)
            adapter.setData(l)
            srl.finishRefresh(1000)
        }

    }
}